<style type="text/css">
  .fl{float:left;}
  .fr{float:right;}
</style>
<extend name="Public/index"/>
<!--  -->
<block name="content">
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
<div id="page-wrapper" style="height: 850px;">
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">商品修改</h1>
        </div>
        <!-- /.col-lg-12 -->
    </div>
   <div class="row col-md-6">
       <div class="col-lg-12">
           <div class="panel panel-default">
               
               <div class="panel-body">
                   <div class="row">
                       <div class="col-lg-12">
                           <form role="form" action="{:U('Admin/Goods/update')}" method="post" enctype="multipart/form-data">  
                           <input type="hidden" name="id" value="{$goods['id']}">       
                              <div class="form-group">
                                  <label>所属分类</label>
                                  <select name="cid" class="form-control">
                                     <foreach name="cates" item="vo" key="k" > 
                                       <option value="{$vo.id}" <if condition="$cname eq $vo.name ">selected = selected</if>>{$vo.name}</option>
                                       </foreach>
                                  </select>
                              </div>
                                
                               <div class="form-group">
                                   <label>商品名称</label>
                                   <input name="username" value="{$goods['username']}"  class="form-control">
                               </div>
                               <div class="form-group">
                                   <label>成本价</label>
                                   <input type="text" name="price" value="{$goods['price']}" class="form-control">
                               </div>
                               <div class="form-group">
                                   <label>库存</label>
                                   <input type="text" name="stock" value="{$goods['stock']}" class="form-control">
                               </div>
                              <div class="form-group">
                                  <label>比率</label>
                                  <input type="text" name="discount" value="{$goods['discount']}" class="form-control">
                              </div>
                              <!--  <div class="form-group">
                                   <label>ÉÌÆ·Í¼Æ¬</label>
                                   <input name="pic" type="file">
                               </div> -->
                              <div class="form-group">
                                  <label>商品标题</label>
                                  <input type="text" name="gtitle" value="{$goods['gtitle']}" class="form-control">
                              </div>
                                <div class="form-group">
                                   <label>商品详情</label>
                                   <script id="editor" name="porfile" type="text/plain" style="width:460px;height:150px;">{$res}</script>

                                </div>
                               <!-- <div class="form-group">
                                   <label>ÑéÖ¤Âë</label>
                                   <input name="vcode" class="form-control">
                                   <img src="{:U('Admin/Public/CreateVcode')}" onclick="this.src=this.src+'?a'" alt="">
                               </div> -->


                               <button class="btn btn-info" type="submit">提交</button>
                               <button class="btn btn-warning" type="reset">重置</button>
                           </form>
                       </div>
                   </div>
                   <!-- /.row (nested) -->
               </div>
               <!-- /.panel-body -->

           </div>

           <!-- /.panel -->
       </div>
       <!-- /.col-lg-12 -->
   </div>
<!-- Í¼Æ¬ÐÞ¸Ä -->
       <div class="col-md-4"  >
       <foreach name="gimg" item="vo" key="k" > 
         <div class="thumbnail xianbei">
           <img src="{$vo['src']}" width="300px">
           <div class="caption">
             <h3></h3>
             <p></p>
             <p>
             <button class="btn btn-primary del" value="{$vo.id}" style="float:right;" role="button">删除图片</button> 
             <button class="btn btn-default fm" value="{$vo.id}" role="button">设封面</button></p>
           </div>
         </div>
       </foreach>
           <a href="{:U('Admin/Goods/addimg',array('id'=>$vo['gid']))}" class="btn btn-danger add"   type="reset">添加图片</a>
       </div>
  
</div>

<script type="text/javascript" src="__PUBLIC__/Admin/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">



  $('.fm').click(function(){

    var id = $(this).attr('value');
    // alert(id);
    var url = "{:U('Admin/Goods/ajaxdel')}";
    // // alert(url);
    var td = $(this);
    //ajax
    
    $.get(url,{id:id},function(data){
      // console.log(data);
       // if (data==1) {
       //      td.find('span').attr('class','glyphicon glyphicon-ok');
       // }else if(data==0) {
       //      td.find('span').attr('class','glyphicon glyphicon-remove');
       // }else{
       //  // alert('修改失败');
       // }
    })

  })
  $('.del').click(function(){

    var id = $(this).attr('value');
    // alert(id);
    var url = "{:U('Admin/Goods/ajaxdel1')}";
    // // alert(url);
    var td = $(this);
    //ajax
    
    $.get(url,{id:id},function(data){
      console.log(data);
       if (data==1) {
         td.parents('.xianbei').remove();
       }else{
           alert('修改失败'); 

       }
    })

  })


</script>











<script type="text/javascript">


    var ue = UE.getEditor('editor',{
     toolbars: [
         ['fullscreen', 'source', 'undo', 'redo'],
         ['bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc']
     ]
    });

</script>
</block>